<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>姓名案例2</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="root">
        <div>
            姓:<input type="text" v-model="firstName"> <br>
            名:<input type="text" v-model="lastName"> <br>
            <!-- 如果要展示方法调用的结果则需要加上()调用 -->
            全名:<span>{{show()}}</span>
        </div>
    </div>
    <script>
        //程序功能  双向绑定姓名输出  
        //但是如果需求增加，需要姓名翻转大写，再截取等此时插值语法中会过于复杂
        Vue.config.productionTip = false
        var vm = new Vue({
            el: '#root',
            data: {
                firstName: 'yu',
                lastName: 'xiaoyao'
            },
            methods: {
                show() {
                    return this.firstName + '-' + this.lastName
                }
            }
        });
    </script>
</body>

</html>